package com.gitee.W_Jun;

/**
 * @author https://gitee.com/W_Jun
 * @date 2021-12-20 0:35
 * @Description 获取ClassLoader的途径
 */
public class ClassLoaderTest2 {
    public static void main(String[] args) {
        try {
            //方式一
            ClassLoader classLoader = Class.forName("java.lang.String").getClassLoader();
            System.out.println(classLoader);
            //方式二
            ClassLoader classLoader1 = Thread.currentThread().getContextClassLoader();
            System.out.println(classLoader1);
            //方式三
            ClassLoader classLoader2 = ClassLoader.getSystemClassLoader().getParent();
            System.out.println(classLoader2);
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
    }
}
